package com.ss.android.video;

import android.content.Context;
import android.view.ViewGroup;

import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.video.IVideoController;
import com.ss.android.article.common.e.IVideoControllerSupplier;
import com.ss.android.video.b.TTVideoController;

import java.util.EnumSet;

public class VideoControllerSupplier implements IVideoControllerSupplier {
    public VideoControllerSupplier() {

    }

    public final IVideoController createVideoController(Context context, ViewGroup container, boolean isFromFeed) {
        if (AppData.getInstance().isTTEngineEnable()) {
            return new TTVideoController(context, container, isFromFeed);
        } else {
            return new VideoController(context, container, isFromFeed);
        }
    }

    public final IVideoController createVideoController(Context context, ViewGroup container, boolean isFromFeed, EnumSet enumSet) {
        if (AppData.getInstance().isTTEngineEnable()) {
            return new TTVideoController(context, container, isFromFeed, enumSet);
        } else {
            return new VideoController(context, container, isFromFeed, enumSet);
        }

    }

    public final void releaseVideoControllerInstance() {
        if (AppData.getInstance().isTTEngineEnable()) {
            TTVideoController.releaseInstance();
        } else {
            VideoController.releaseInstance();
        }
    }

    public final IVideoController getVideoControllerInstance() {
        if (AppData.getInstance().isTTEngineEnable()) {
            return TTVideoController.getInstance();
        } else {
            return VideoController.getInstance();
        }
    }

    public final IVideoController createVideoControllerDirectly(Context context, ViewGroup container, boolean isFromFeed, EnumSet enumSet) {
        return new VideoController(context, container, isFromFeed, enumSet);
    }
}

